

<style>
.btns{ border:1px solid; display:inline-block; cursor :pointer;}
.hiddens{display:none!important;  }
</style>
<div class="span10" id="datacontent">
    <ul class="breadcrumb">
        <li><a href="/exercise/index/index">剑雅真题</a> <span class="divider">/</span></li>
        <li class="active">设置人数</li>
    </ul>
    
        <table class="table table-hover">
            <thead>
            <tr>
                <th width="80">ID</th>
                <th>名称</th>
                <th >做题人数</th>
                <th >操作</th>
            </tr>
            </thead>
            <tbody>
            <?php
                foreach($data as $v) {
                    ?>
                    <tr>
                        <td><span><?php echo $v['id']?></span></td>
                        <td><span><?php echo $v['cate_name']?></span></td>
                        <td><span><?php echo $v['num']?></span></td>
                        <td>
                            <div>
                                    <a class="btn" href="<?php echo baseUrl ?>/exercise/set/update?id=<?php echo $v['id'] ?>">修改</a>
                                
                            </div>
                        </td>
                    </tr>

                    <?php
                }
                ?>
            </tbody>
        </table>
</div>

<script>

    var length =$('form').length;
    var length = length-1;
    // 点击修改
    function make(p){
        for(var i=0;i<=length;i++){
            if(p==i){
                // 修改框
                $('.spand'+i).addClass("hiddens");
                $('.input'+i).removeClass("hiddens");
                   // 按钮
                $('.make'+i).addClass("hiddens");
                $('.insert'+i).removeClass("hiddens");

            }
            // $('.update'+i )        
        }
        // alert(length);
    }
    // 点击提交
    function insert(p){
        for(var i=0;i<=length;i++){
            if(p==i){
                // 修改框
                $('.input'+i).addClass("hiddens");
                $('.spand'+i).removeClass("hiddens");
                var spanleng =  $('.spand'+i).length;
                for(var c=0;c<=spanleng;c++){
                    val = $('.input'+i).eq(c).val(); 
                    $('.spand'+i).eq(c).text(val); 
                }
                // 按钮
                $('.insert'+i).addClass("hiddens");
                $('.make'+i).removeClass("hiddens");

                var form = $("#form"+i).serialize();
                var id = $(".id"+i).text();
                // alert(form);
                $.ajax({
                    url : '/ielts/api/learningplan-update',
                    type: 'post',
                    data: $.param({'id':id})+'&'+form,
                    dataType: 'json',
                    success: function(data) {
                    if(data){//提交成功下一题
                    //     for( i=0; i<=leng;i++){
                    //         if(order==i){
                    //         if(val==''){
                    //             $('.lisdate').eq(i).text('口语评分');
                    //     }else{
                    //         $('.lisdate').eq(i).text(val);
                    // }
                    // }}
            // alert(val);
            // window.location.href="/cn/exerciselistendo/dolistenexercisesubdiff?exerciseid="+exerciseid;
        }else{
            aler("修改失败！")
    }}
  })    
            }
  
        }

    }





</script>


